package com.mocha;


import cn.hutool.core.util.RandomUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;


/**
 * @author: songkui
 * @since: 2024/3/21 0:14
 */
@Component
@Order
@Slf4j
@AllArgsConstructor
public class SocketStartInitialize implements ApplicationRunner {

    @Override
    public void run(ApplicationArguments args) throws Exception {

        int cs = 500;

//        final CountDownLatch latch = new CountDownLatch(cs);
        String userP = "User_"+ RandomUtil.randomString(3)+"_";
        for (int i = 0; i< 1; i++){
                int finalI1 = i;
                SocketClient client = new SocketClient();
                client.startClient(userP+ finalI1);
                ClientManager.getInstance().put(client);

            TimeUnit.MILLISECONDS.sleep(RandomUtil.randomInt(300, 400));
            System.out.println("-------i---"+ i +"-----------");
            client.sendSwitchCamera("ALL");

        }


    }



}
